<%--
  Created by IntelliJ IDEA.
  User: 86183
  Date: 2019/8/19
  Time: 14:22
  To change this template use File | Settings | File Templates.
  //用户管理显示页面
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath(); %>
<jsp:include page="/manage/inc/header"></jsp:include>
<link rel="stylesheet" type="text/css" href="<%=path%>/Manage/static/css/shou.css"/>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div class="main-wrap">

    <div class="crumb-wrap">

        <div class="crumb-list"><i class="icon-font"></i><a href="${pageContext.request.contextPath}/manage">首页</a><span class="crumb-step">&gt;</span><a href="${pageContext.request.contextPath}/manage/show/userinfoshow">遗失者管理</a>   &nbsp;&nbsp;&nbsp;&nbsp;             </span><a class="yitingfeng" style="color: #ff231e" href="#">(已停封)</a></div>
    </div>
    <div class="search-wrap">
        <div class="search-content">

                <table class="search-tab">
                    <tr>
                        <div class="form-row">
                            <div class="form-group col-md-12">
                                <label>按城市查看:</label>
                                <select id="province" class="form-control custom-select" style="width:150px; " name="provinceId">
                                    <option value="-9">请选择</option>
                                    <c:forEach items="${requestScope.root}" var="area">
                                        <option value="${area.areaId}">${area.areaName}</option>
                                    </c:forEach>
                                </select>
                                <select id="city" name="cityId " class="form-control custom-select" style="width:150px; ">
                                </select>
                                <select id="area" name="areaId" class="form-control custom-select" style="width:150px; ">
                                </select>
                            </div>

                        <th width="70">搜索:</th>
                        <td><input class="common-text" placeholder="搜索" name="keywords"  id="matter" type="text"></td>
                        <td><input class="btn btn-primary btn2" name="sub" value="查询" id="seek" type="button"></td>
                    </tr>
                </table>
        </div>
    </div>
    <div class="result-wrap">
        <form name="myform" id="myform" method="post">
            <div class="result-title">
                <div class="result-list">
                </div>
            </div>
            <div class="result-content" id="show">


            </div>
        </form>
    </div>
</div>
<!--/main-->
</div>
<jsp:include page="/manage/inc/footer"></jsp:include>


<script>




$(function () {
    initCities();

    $("#province").change(function () {
        initCities()
    })
    $("#city").change(function () {
        initAreas()
    })

    initData(1);



})
$(".yitingfeng").click(function () {
    var action ="${pageContext.request.contextPath}/manage/ajaxJsp/sethonor";
    $.post(action,function (mes) {
        $("#show").html(mes);
    })

})


    function initData(pageNum)
    {
        var pageNum = {pageNum: pageNum};
        $.post("${pageContext.request.contextPath}/manage/ajaxJsp/usershow", pageNum, function (mes) {
                $("#show").html(mes);
            }
        );

    }
    $("#seek").click(function () {
        var province = $("#province").val();
        var city   = $("#city").val();//市
        var area   = $("#area").val();//区
        if(province==-9) province="";
        if(city==null) city="";
        if(area==null) area="";
                var action ="${pageContext.request.contextPath}/manage/ajaxJsp/usershow1";
                var name =$("#matter").val();
                if (name!=null)
                {
                    $.post(action,{name:name,province:province,city:city,area:area},function (mes) {
                        $("#show").html(mes);
                    })

                }
                else {
                    return false;
                }

    })
function initCities() {
    var provinceId = $("#province").val();
    $("#city").empty();
    $("#area").empty();
    if (provinceId != "null")
    {
        $.ajax({

            url: "${pageContext.request.contextPath}/web/information/cities",
            data: {"areaId": provinceId},
            type: "get",
            dataType: "json",
            success: function (cities) {
                    for (var i = 0; i < cities.length; i++) {
                        $("#city").append("<option value=\"" + cities[i].areaId + "\">" + cities[i].areaName + "</option>")
                    }

                $.getJSON("${pageContext.request.contextPath}/web/information/cities", {areaId: $("#city").val()}, function (cities) {


                        for (var i = 0; i < cities.length; i++) {
                            $("#area").append("<option value=\"" + cities[i].areaId + "\">" + cities[i].areaName + "</option>")
                        }

                });
            }
        });
    }
}
function initAreas() {
    var areaId = $("#city").val();
    $("#area").empty();
    $.ajax({
        url: "${pageContext.request.contextPath}/web/information/cities",
        data: {"areaId": areaId}, type: "get", dateType: "json",
        success: function (mes) {

                for (var i = 0; i < mes.length; i++) {
                    $("#area").append("<option value=\"" + mes[i].areaId + "\">" + mes[i].areaName + "</option>")
                }

        }
    })
}




</script>